package mytweetdiary.ds;

import com.google.appengine.api.users.User;

import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable
public class TwitterInfo {
	@PrimaryKey
	private String email;

	@Persistent
	private User user;

	@Persistent
	private String accessToken;

	@Persistent
	private String accessSecret;

	@Persistent
	private String requestToken;

	@Persistent
	private String requestSecret;

	public TwitterInfo(User user) {
		this.email = user.getEmail();
		this.user = user;
		accessToken = accessSecret = null;
	}

	public String getEmail() {
		return email;
	}

	public User getUser() {
		return user;
	}

	public boolean isAuthorized() {
		return (accessToken != null);
	}

	public String getAccessToken() {
		return accessToken;
	}

	public void setAccessToken(String accessToken) {
		this.accessToken = accessToken;
	}

	public String getAccessSecret() {
		return accessSecret;
	}

	public void setAccessSecret(String accessSecret) {
		this.accessSecret = accessSecret;
	}

	public String getRequestToken() {
		return requestToken;
	}

	public void setRequestToken(String requestToken) {
		this.requestToken = requestToken;
	}

	public String getRequestSecret() {
		return requestSecret;
	}

	public void setRequestSecret(String requestSecret) {
		this.requestSecret = requestSecret;
	}
	
	public String toString() {
		return "Access Token : " + accessToken + ", Access Secret : "
				+ accessSecret + ", Request Token : " + requestToken
				+ ", Request Secret" + requestSecret;
	}
}
